home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / as / dist / messages.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-01  |  3.5 KB  |  153 lines

  1. /* messages.c - error reporter -
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GAS, the GNU Assembler.
  5.  
  6. GAS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GAS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GAS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include <stdio.h>        /* define stderr */
  21. #include "as.h"
  22. #ifndef NO_VARARGS
  23. #include <varargs.h>
  24. #endif
  25.  
  26. /*
  27.         ERRORS
  28.  
  29.     We print the error message 1st, beginning in column 1.
  30.     All ancillary info starts in column 2 on lines after the
  31.     key error text.
  32.     We try to print a location in logical and physical file
  33.     just after the main error text.
  34.     Caller then prints any appendices after that, begining all
  35.     lines with at least 1 space.
  36.  
  37.     Optionally, we may die.
  38.     There is no need for a trailing '\n' in your error text format
  39.     because we supply one.
  40.  
  41. as_warn(fmt,args)  Like fprintf(stderr,fmt,args) but also call errwhere().
  42.  
  43. as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
  44.  
  45. */
  46.  
  47.  
  48.  
  49. /*
  50.  *            a s _ w a r n ( )
  51.  *
  52.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
  53.  * in input file(s).
  54.  * Please only use this for when we have some recovery action.
  55.  * Please explain in string (which may have '\n's) what recovery was done.
  56.  */
  57.  
  58. #ifdef NO_VARARGS
  59. /*VARARGS1*/
  60. as_warn(Format,args)
  61. char *Format;
  62. {
  63.   if ( ! flagseen ['W'])    /* -W supresses warning messages. */
  64.     {
  65.       as_where();
  66.       _doprnt (Format, &args, stderr);
  67.       (void)putc ('\n', stderr);
  68.       /* as_where(); */
  69.     }
  70. }
  71. #else
  72. void
  73. as_warn(Format,va_alist)
  74. char *Format;
  75. va_dcl
  76. {
  77.   va_list args;
  78.  
  79.   if( ! flagseen['W'])
  80.     {
  81.       as_where();
  82.       va_start(args);
  83.       vfprintf(stderr, Format, args);
  84.       va_end(args);
  85.       (void) putc('\n', stderr);
  86.     }
  87. }
  88. #endif
  89. #ifdef DONTDEF
  90. void
  91. as_warn(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  92. char *format;
  93. {
  94.     if(!flagseen['W']) {
  95.         as_where();
  96.         fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  97.         (void)putc('\n',stderr);
  98.     }
  99. }
  100. #endif
  101. /*
  102.  *            a s _ f a t a l ( )
  103.  *
  104.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
  105.  * message, and locate stdsource in input file(s).
  106.  * Please only use this for when we DON'T have some recovery action.
  107.  * It exit()s with a warning status.
  108.  */
  109.  
  110. #ifdef NO_VARARGS
  111. /*VARARGS1*/
  112. as_fatal (Format, args)
  113. char *Format;
  114. {
  115.   as_where();
  116.   fprintf(stderr,"FATAL:");
  117.   _doprnt (Format, &args, stderr);
  118.   (void)putc ('\n', stderr);
  119.   /* as_where(); */
  120.   exit(42);            /* What is a good exit status? */
  121. }
  122. #else
  123. void
  124. as_fatal(Format,va_alist)
  125. char *Format;
  126. va_dcl
  127. {
  128.   va_list args;
  129.  
  130.   as_where();
  131.   va_start(args);
  132.   fprintf (stderr, "FATAL:");
  133.   vfprintf(stderr, Format, args);
  134.   (void) putc('\n', stderr);
  135.   va_end(args);
  136.   exit(42);
  137. }
  138. #endif
  139. #ifdef DONTDEF
  140. void
  141. as_fatal(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  142. char *Format;
  143. {
  144.   as_where();
  145.   fprintf (stderr, "FATAL:");
  146.   fprintf(stderr, Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  147.   (void) putc('\n', stderr);
  148.   exit(42);
  149. }
  150. #endif
  151.  
  152. /* end: messages.c */
  153.